cmake_minimum_required(VERSION 3.10)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
project(RealEngine)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)


set(VULKAN_SDK "" CACHE PATH "Vulkan SDK根目录")

option(ALICE_VULKAN "Enable ALICE_VULKAN macro" OFF)

option(ALICE_JS_CEF_PORT "Enable ALICE_JS_CEF_PORT macro" OFF)

set(ALICE_PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(THIRD_PARTY_ROOT "G:/ThirdPartySDK")
include("${ALICE_PROJECT_ROOT}/cmake/common.cmake")

include_directories(${ALICE_PROJECT_ROOT})
include_directories("${THIRD_PARTY_ROOT}/glew-2.1.0/include")
GroupDirectories("Launcher/Windows" "${ALICE_PROJECT_ROOT}/Launcher/Windows" "${ALICE_PROJECT_ROOT}/Launcher/Windows" AllSrcFiles)
GroupDirectories("Runtime" "${ALICE_PROJECT_ROOT}/Runtime" "${ALICE_PROJECT_ROOT}/Runtime" RuntimeSrcFiles)

set(RealEngine_SRCS
  ${AllSrcFiles}
  ${RuntimeSrcFiles}
)
if(ALICE_JS_CEF_PORT)
    add_definitions(-DALICE_JS_CEF_PORT)
    message(STATUS "ALICE_JS_CEF_PORT is enabled")
else()
    message(STATUS "ALICE_JS_CEF_PORT is disabled")
endif()
if(WIN32)
    add_library(libglew32_lib STATIC IMPORTED)
    set_target_properties(libglew32_lib PROPERTIES
        IMPORTED_LOCATION "${THIRD_PARTY_ROOT}/glew-2.1.0/lib/Release/x64/glew32.lib"
        IMPORTED_LOCATION_DEBUG "${THIRD_PARTY_ROOT}/glew-2.1.0/lib/Debug/x64/glew32.lib"
        IMPORTED_LOCATION_RELEASE "${THIRD_PARTY_ROOT}/glew-2.1.0/lib/Release/x64/glew32.lib"
    )
    add_definitions(-DUNICODE -D_UNICODE)
    add_executable(RealEngine ${RealEngine_SRCS})
    target_link_libraries(RealEngine libglew32_lib)
    if(ALICE_VULKAN)
        add_definitions(-DALICE_VULKAN)
        include_directories("${VULKAN_SDK}/Include")
        add_library(libvulkan STATIC IMPORTED)
        set_target_properties(libvulkan PROPERTIES
            IMPORTED_LOCATION "${VULKAN_SDK}/Lib/vulkan-1.lib"
            IMPORTED_LOCATION_DEBUG "${VULKAN_SDK}/Lib/vulkan-1.lib"
            IMPORTED_LOCATION_RELEASE "${VULKAN_SDK}/Lib/vulkan-1.lib"
        )
        target_link_libraries(RealEngine libvulkan)
        message(STATUS "ALICE_VULKAN is enabled")
    else()
        message(STATUS "ALICE_VULKAN is disabled")
    endif()
    if(CMAKE_GENERATOR MATCHES "Visual Studio")
        set_target_properties(RealEngine PROPERTIES
            VS_DEBUGGER_WORKING_DIRECTORY "${ALICE_PROJECT_ROOT}/Debug"
        )
    endif()
endif()